F.module("/static/widget/question/answer-deal/replyer/replyer.js",
function(a, e) {
    var c = a("/static/common/lib/tangram/base/base.js");
    var h = a("/static/question/ui/editor/editor.js");
    var k = a("/static/common/ui/submit/submit.js");
    var g = a("/static/common/ui/event/event.js");
    var l = a("/static/common/ui/complain/complain.js");
    var f = a("/static/question/ui/forward/forward.js");
    var j = a("/static/common/ui/dialog/dialog.js");
    var d = a("/static/common/ui/log/log.js");
    var n = a("/static/common/ui/tip/tip.js");
    g.on("replyask.close",
    function(p, q) {
        c("#pump-reply-" + q + ",#modify-reply-" + q).filter(".cancel-deal").click()
    });
    function b(s) {
        var p = c.isString(s.controller) ? c("#" + s.controller) : c(s.controller),
        q = null;
        var r = F.context("answers")[s.id];
        s.raid = r.raid;
        data = F.context("editreplyask-" + r.raid) || r;
        p.click(function(v) {
            if (!q) {
                q = new h(s.editorConfig);
                q.instance.initAttach();
                c(q.submitBtn).click(function(w) {
                    g.fire("login.check", {
                        isLogin: function() {
                            m(q, s)
                        }
                    });
                    w.preventDefault()
                });
                if (q.type == "modifyanswer") {
                    var u = data.isReplyAsk ? c("#replyask-content-" + s.raid + " .answer-oldmap") : c("answer-content-" + s.id).parent().find(".answer-oldmap");
                    if (u.length) {
                        data.con += '<p><iframe data-type="map" map="' + u[0].src + '" frameborder="0" class="answer-map" src="' + u[0].src + '" ></iframe></p>'
                    }
                    if (data && data.con) {
                        var t = F.context("answer-file") && F.context("answer-file")[r.raid || s.id];
                        if (t) {
                            q.setContent(data.con.replace(/<file[^>]* \/>/ig, ""), data.rich);
                            if (c.type(q.instance.setUploadFile) == "function") {
                                q.instance.setUploadFile(t)
                            }
                        } else {
                            q.setContent(data.con, data.rich)
                        }
                    }
                }
            } else {
                if (!c(this).hasClass("cancel-deal") && q.type == "modifyanswer") {
                    var t = F.context("answer-file") && F.context("answer-file")[r.raid || s.id];
                    if (t && c.type(q.instance.setUploadFile) == "function") {
                        q.instance.setUploadFile(t)
                    }
                }
            }
            if (c(this).hasClass("cancel-deal")) {
                c(this).removeClass("cancel-deal").html("<em><b>" + s.btnText[0] + "</b></em>");
                q.collapseEditor(290);
                if (c.type(q.instance.uploadAction) == "function") {
                    q.instance.uploadAction("cancel")
                }
            } else {
                c(this).addClass("cancel-deal").html("<em><b>" + s.btnText[1] + "</b></em>");
                q.expandEditor(290);
                g.fire("comment.close", s.id)
            }
            v.preventDefault()
        })
    }
    function m(q, u) {
        if (!q.checkEditor()) {
            return
        }
        var t = F.context("answers")[u.id] || {};
        var p = {
            cm: 100010,
            qid: t.qid,
            aid: u.id,
            rid: u.id
        };
        var s = t.raid || "";
        if (s != "") {
            c.object.extend(p, {
                raid: s,
                cm: q.type == "modifyanswer" ? "100401": "100400"
            })
        }
        c.object.extend(p, q.editorSubmit());
        new k({
            params: p,
            hasJump: true,
            syncId: q.type,
            authcode: q.authcode || null
        });
        var r = "";
        if (p.co && p.co.match(/<strong>/) && p.co.match(/<em>/)) {
            r = "both"
        } else {
            if (p.co && p.co.match(/<strong>/)) {
                r = "replyBold"
            } else {
                if (p.co && p.co.match(/<em>/)) {
                    r = "replyRed"
                }
            }
        }
        d.send({
            type: 2014,
            page: "qb-new",
            privilegeSubmit: r
        })
    }
    function i(q) {
        var p = null;
        if (F.context("answers")[q] && F.context("answers")[q].replyAskNum) {
            p = 999
        } else {
            p = 9999
        }
        return p
    }
    function o(v, q, p) {
        if (c("#pump-reply-" + v).get(0)) {
            b({
                id: v,
                controller: "pump-reply-" + v,
                btnText: ["继续回答", "取消回答"],
                editorConfig: {
                    id: "editor-" + v,
                    type: "pumpanswer",
                    config: {
                        maximumWords: i(v)
                    }
                }
            });
            if (String(c.url.getQueryValue(location.href, "from")).indexOf("comment") == -1) {
                c(function() {
                    c("#pump-reply-" + v).click()
                })
            }
        }
        if (c("#modify-reply-" + v).get(0)) {
            b({
                id: v,
                controller: "modify-reply-" + v,
                btnText: ["完善我的回答", "取消修改"],
                editorConfig: {
                    id: "editor-" + v,
                    type: "modifyanswer",
                    config: {
                        maximumWords: i(v)
                    }
                }
            })
        }
        if (c("#forward-reply-" + v).get(0)) {
            var t = F.context("answers")[v] || {};
            c("#forward-reply-" + v).click(function(w) {
                w.preventDefault();
                if (p <= 0) {
                    j.alert("今天您自荐了5个答案，已达到上限，为了保证知道专家评审优质答案的质量，明天再来吧！", {
                        height: 170
                    });
                    d.send({
                        type: 2014,
                        page: "question",
                        action: "forward-limit",
                        pos: "click",
                        uid: F.context("user").id
                    })
                } else {
                    if (q <= 0) {
                        j.alert(["<p>当前分类下自荐答案量已达上限啦，为保证知道专家评审优质答案的质量，限制每日接受自荐答案5000个，明天再来吧！</p>", '<p>了解<a href="http://zhidao.baidu.com/s/quality/" target="_blank">优质答案标准</a>，提高回答质量，可以增加自荐成功率哦~</p>'].join(""), {
                            height: 220
                        });
                        d.send({
                            type: 2014,
                            page: "question",
                            action: "forward-max",
                            pos: "click",
                            uid: F.context("user").id
                        })
                    } else {
                        f.init(t.qid, v);
                        d.send({
                            type: 2014,
                            page: "question",
                            action: "forward-pass",
                            pos: "click",
                            uid: F.context("user").id
                        })
                    }
                }
            });
            d.send({
                type: 2014,
                page: "question",
                action: "forward-" + (p <= 0 ? "limit": (q <= 0 ? "max": "pass")),
                pos: "load"
            })
        }
        if (c("#del-reply-" + v).get(0)) {
            c("#del-reply-" + v).click(function(x) {
                x.preventDefault();
                if (c(this).hasClass("btn-24-disabled")) {
                    return
                } else {
                    var w = new j({
                        titleText: "知道提示",
                        type: "confirm",
                        width: 300,
                        height: 210,
                        content: '<div class="pl-20">删除当前回答需要花费<span class="f-red ml-5 mr-5">50</span>财富值<p>您当前持有<span class="f-red ml-5 mr-5">' + F.context("user").wealth + '</span>财富值<br/>确定删除吗？<br/><p class="f-aid mt-10">tips:删除回答不影响采纳率</p></div>',
                        autoDispose: true,
                        onaccept: function() {
                            w.hide();
                            var y = {
                                cm: 100016,
                                qid: F.context("page")["qid"],
                                aid: v,
                                rid: v
                            };
                            new k({
                                url: "/submit/ajax",
                                params: y,
                                beforeJump: function() {
                                    var z = new j({
                                        width: 350,
                                        height: 160,
                                        titleText: "知道提示",
                                        content: '<div class="mt-20">删除回答成功啦~~</div>',
                                        autoDispose: true
                                    });
                                    z.on("hide",
                                    function() {
                                        window.location.reload(true)
                                    });
                                    setTimeout(function() {
                                        z.hide()
                                    },
                                    1000)
                                },
                                errorDeal: function() {
                                    j.alert("删除回答失败了: (")
                                }
                            })
                        }
                    })
                }
            });
            var u, r, s;
            c("#del-reply-" + v).mouseover(function(z) {
                z.stopPropagation();
                var y = this;
                if (!c(this).hasClass("btn-24-disabled")) {
                    return
                }
                if (c(".del-answer-tip").size()) {
                    return
                }
                var x = ['<p class="f-12">删除当前回答需要花费<span class="f-red ml-5 mr-5">50</span>财富值</p>', '<p class="f-12">您当前持有', '<span class="f-red ml-5 mr-5">', F.context("user").wealth, "</span>财富值，无法删除</p>", '<a href="http://zhidao.baidu.com/browse/" target="_blank" class="f-12">', "立刻去答题，赚取更多财富值", "</a>"].join(""),
                w = {
                    width: 220,
                    skin: "del-answer-tip",
                    closebox: false,
                    offset: [0, 0],
                    autoDispose: true,
                    closebox: true,
                    direction: "down",
                    content: x
                };
                s = new n(w);
                u = setTimeout(function() {
                    clearTimeout(r);
                    s.show(y)
                },
                200)
            }).mouseout(function(y) {
                y.stopPropagation();
                var x = this;
                function w(z) {
                    clearTimeout(r);
                    r = setTimeout(function() {
                        if (! (c(s.getTipContainer()).contains(z.target) || c(z.target).closest(".btn").get(0) == x)) {
                            clearTimeout(u);
                            s.hide();
                            c(document).unbind("mousemove", w)
                        }
                    },
                    200)
                }
                c(document).mousemove(w)
            })
        }
    }
    e.init = o;
    return e
},
["/static/common/lib/tangram/base/base.js", "/static/question/ui/editor/editor.js", "/static/common/ui/submit/submit.js", "/static/common/ui/event/event.js", "/static/common/ui/complain/complain.js", "/static/question/ui/forward/forward.js", "/static/common/ui/dialog/dialog.js", "/static/common/ui/log/log.js", "/static/common/ui/tip/tip.js"]);
F.module("/static/widget/question/ask/replyer/replyer.js",
function(a, f) {
    var c = a("/static/common/lib/tangram/base/base.js");
    var i = a("/static/question/ui/editor/editor.js");
    var e = a("/static/common/ui/log/log.js");
    var h = a("/static/common/ui/event/event.js");
    var l = a("/static/common/ui/submit/submit.js");
    a("/static/common/ui/baidu/baidu.js");
    var b = c("#answer-editor");
    _controller = c("#answer-bar"),
    _arrow = c("#answer-bar i").get(0);
    var j = {
        ql: /browse(?:\/\d+(?:$|\?lm=2|\?[^lm])|$|\/$|\/\?lm=2)/i,
        ql_tab_hscore: /browse\/\d*\?lm\=4/,
        ql_tab_zero: /browse\/\d*\?lm\=8/,
        ql_tab_emergency: /browse\/\d*\?lm\=16/,
        zhuanti: /zhidao\.baidu\.com\/s\/([a-zA-Z0-9_\-]+)/,
        search: /zhidao\.baidu\.com\/search/
    }; (function() {
        var q = document.referrer;
        var p = "",
        m;
        for (var o in j) {
            m = q.match(j[o]);
            if (m) {
                p = o;
                break
            }
        }
        if (p && p == "zhuanti") {
            p = m[1]
        }
        if (!p) {
            var s = c.url.queryToJson(location.search || "");
            if (s && s.fr == "uc_push") {
                if (s.push == "keyword") {
                    p = "uc_tab_keyword"
                } else {
                    if (s.push == "category") {
                        p = "uc_tab_class"
                    } else {
                        p = "uc_tab_recommand"
                    }
                }
            }
        }
        var n = F.context("page").isFromWap;
        var r = p + (parseInt(n) ? ";wap_question_replyed": "");
        F.context("extra", {
            title: r,
            answerfr: r
        })
    })();
    var g = null,
    k = {
        type: "answer",
        id: "answer-editor"
    };
    _controller.click(function() {
        if (g === null) {
            g = new i(k);
            c(g.submitBtn).click(d)
        }
        if (_arrow.className == "i-arrow-down") {
            g.expandEditor(290);
            _arrow.className = "i-arrow-up"
        } else {
            g.collapseEditor(290);
            _arrow.className = "i-arrow-down"
        }
    }); (function() {
        var q = {
            home: {
                keyword: /push=keyword/,
                category: /push=category/,
                recommend: /push=(core|reduce|cookie)/,
                asking: /push=asking/
            },
            browse: {
                emergent: /emergent/,
                reward: /lm=(4|9472)/,
                difficult: /lm=18/,
                "default": /lm=(0|2|8960)/
            },
            uhome: {
                keyword: /push=keyword/,
                category: /push=category/,
                help: /push=help/,
                recommend: /push=(core|reduce|cookie)/
            },
            search: {},
            submit: {},
            question: {},
            "new": {}
        };
        var r = {
            home: /zhidao\.baidu\.com\/$/,
            topic: /zhidao\.baidu\.com\/s\/([a-zA-Z0-9_\-]+)/,
            baidu: /www\.baidu\.com/
        };
        var m = ["qb"],
        p = document.referrer,
        n = location.href;
        if (p == "") {
            m.push("none")
        } else {
            var o = hasFindYet = false;
            c.object.each(r,
            function(t, s) {
                if (p.match(t)) {
                    m.push(s);
                    if (s in q) {
                        c.object.each(q[s],
                        function(v, u) {
                            if (!o && n.match(v)) {
                                m.push(u);
                                o = true
                            }
                        })
                    }
                }
            });
            if (!o) {
                c.object.each(q,
                function(t, s) {
                    if (p.match("zhidao.baidu.com/" + s)) {
                        m.push(s);
                        if (!c.object.isEmpty(t)) {
                            var u = s == "browse" ? p: n;
                            c.object.each(t,
                            function(w, v) {
                                if (!hasFindYet && u.match(w)) {
                                    m.push(v);
                                    hasFindYet = true
                                }
                            })
                        }
                    }
                })
            }
        }
        F.context("extra")["entry"] = m.join("_") || ""
    })();
    function d(n) {
        n.preventDefault();
        var o = {
            cm: 100009,
            qid: F.context("page")["qid"],
            title: F.context("extra")["title"],
            answerfr: F.context("extra")["answerfr"],
            entry: F.context("extra")["entry"]
        };
        if (g.checkEditor()) {
            if (location.search && c.url.getQueryValue(location.href, "newUserGuide")) {
                o.newUserGuide = c.url.getQueryValue(location.href, "newUserGuide")
            }
            c.object.extend(o, g.editorSubmit());
            var m = "";
            if (o.co && o.co.match(/<strong>/) && o.co.match(/<em>/)) {
                m = "both"
            } else {
                if (o.co && o.co.match(/<strong>/)) {
                    m = "replyBold"
                } else {
                    if (o.co && o.co.match(/<em>/)) {
                        m = "replyRed"
                    }
                }
            }
            e.send({
                type: 2038,
                page: "qb-new",
                action: "answer",
                privilegeSubmit: m
            });
            h.fire("login.check", {
                isLogin: function() {
                    var p = {
                        tn: "ikqb",
                        qid: F.context("page")["qid"],
                        user: F.context("user")["name"],
                        referrer: encodeURIComponent(document.referrer)
                    };
                    if (F.context("user").replyBold == 1 && o.co && o.co.match(/<strong>/)) {
                        p.bold = 1
                    }
                    if (F.context("user").replyRed == 1 && o.co && o.co.match(/<em>/)) {
                        p.red = 1
                    }
                    e.stat(c.url.jsonToQuery(p));
                    new l({
                        params: o,
                        hasJump: true,
                        syncId: g.type,
                        authcode: g.authcode || null
                    })
                },
                noLogin: function() {
                    if (c.cookie.get("IK_USERVIEW") != "1") {
                        if (c("#anttongji").length) {
                            c.sio("http://tongji.zhidao.baidu.com/common/js/base_widget.js?t=" + (new Date).getTime()).callByBrowser();
                            c.cookie.set("IK_USERVIEW", "1", {
                                path: "/",
                                expires: 28800000
                            })
                        }
                    }
                    h.fire("login.log", {
                        onLoginSuccess: function() {
                            new l({
                                params: o,
                                hasJump: true,
                                syncId: g.type
                            })
                        }
                    })
                }
            })
        }
    }
    if (F.context("page").isView != "1") {
        c(function() {
            c("#answer-editor").css({
                visibility: "hidden",
                height: "0px"
            });
            _controller.click()
        })
    }
    return f
},
["/static/common/lib/tangram/base/base.js", "/static/question/ui/editor/editor.js", "/static/common/ui/log/log.js", "/static/common/ui/event/event.js", "/static/common/ui/submit/submit.js", "/static/common/ui/baidu/baidu.js"]);